import java.util.Iterator;

/*
 * Created by Jesse Phillips
 * Created on Jan 26, 2006
 */
/**
 * For use in the LinkedList class. This is designed to
 * work as a doubly LinkedList.
 * 
 * @author Jesse Phillips
 * @see "No barrowed code."
 */
public class Node<E> {
	private Node next, prev;
	private E element;
	
	/**
	 * Creates an empty node, used to make an empty master Node.
	 */
	public Node() {
		next = null;
		prev = null;
		element = null;
	}
	
	/**
	 * Builds a Node with data. Used when it is going to be the only Node
	 * in the list.
	 * 
	 * @param data What the user wishes to store.
	 */
	public Node(E data) {
		next = null;
		prev = null;
		element = data;
	}
	
	/**
	 * Builds a node that can be insereted anywhere.
	 * 
	 * @param data What the user whishes to store.
	 * @param next The next Node in the list.
	 * @param prev The previous Node in the list.
	 */
	public Node(E data, Node next, Node prev) {
		this.next = next;
		this.prev = prev;
		element = data;
	}
	
	/**
	 * Getter method for the next Node.
	 * 
	 * @return A Node that is next in the link.
	 */
	public Node getNext() {
		return next;
	}
	
	/**
	 * Setter method for what the next Node will be.
	 * 
	 * @param next The Node that should appear next in the link.
	 */
	public void setNext(Node next) {
		this.next = next;
	}
	
	/**
	 * Getter method for the previous Node.
	 * 
	 * @return A Node privious to the current one.
	 */
	public Node getPrev() {
		return prev;
	}
	
	/**
	 * Setter method for what the previous Node was.
	 * 
	 * @param prev
	 */
	public void setPrev(Node prev) {
		this.prev = prev;
	}
	
	/**
	 * Getter method for returning what is stored in the Node.
	 * 
	 * @return The data of type <E>.
	 */
	public E getElement() {
		return element;
	}
	
	/**
	 * Setter method for the element.
	 * 
	 * @param value what it should be changed to.
	 */
	public void setElement(E value) {
		this.element = value;
	}
	
	/**
	 * @return A String using the data's toString.
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return element.toString();
	}
}
